<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 1, 找出下面字符串中的bag,beg,big,bog, 忽略大小写, 并将其改为bug
        var str="I am a Big man, I have so much bag, so everyone call me  beg man,  bog bog bog, I hate you! "
        var reg=/(bag|beg|big|bog)/ig;
        console.log(str.replace(reg,"bug"));

        // 2, 假设有一个多字符的片断重复出现，把"really"、"really really "，
        // 以及任意数量连续出现的"really"字符串换成一个简单的"very ”
        var str="Billy tried really hard Sally tried really really hard Timmy tried really really really hard Johnny tried really really really really hard"
        var reg=/(really\s)+/ig;
        console.log(str.replace(reg,"very "));
    </script>
</body>
</html>